﻿#include <zthread/Runnable.h>  
#include <zthread/Thread.h> 
#include <winsock2.h> 
using namespace ZThread;

//网络接收线程类，只处理图片缓冲区 
class Netprocess:public Runnable{//
    public:
        Netprocess(SOCKET &_socket,int bufferlen); 
        void run();
        void recvImage(SOCKET& socket);
         //分块接收图片数据 
        int my_recv_imagedata(SOCKET& socket,char *imagedata,int length);  
        //封装之后的接受函数  
        //因为要判断每次接收了多少字节  
        int my_recv(SOCKET& socket,char *buf,int length,int flag); 
        int getwidth();       
        int getheight();
        unsigned char * getdataaddr();  
        bool imagebufferIsfull();   
        bool imagebufferIsempty();
        int indexadd(int _index);
        int indexsub(int _index);
        int buffercount(); 
        bool connected();
        void myyuv422_rgb(const unsigned char * yuvdata,unsigned char * rgbdata,int width,int height);
        
    private:
        int recvframecount;
        int recv0count;
        SOCKET netsocket;      
        bool isconnected;        
        int databuffercapacity;
        int bufferheadindex;
        int bufferendindex;
        int imagewidth;
        int imageheight;
        unsigned char * databuffer;
};

